package org.spring.aicloud.util;

import lombok.Data;

import java.io.Serializable;

/**
 * 统一的返回对象
 * 进行Ajax响应
 */
@Data
public class ResponseEntity implements Serializable {
    private static final long serialVersionUID = 1L;
   private int code; // 返回的状态码
   private String msg; // 返回的描述信息
   private Object data; //返回的数据
    public static ResponseEntity success(Object data){
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setCode(200);
        responseEntity.setMsg("success");
        responseEntity.setData(data);
        return responseEntity;
    }
    public static ResponseEntity fail(String msg){
        ResponseEntity responseEntity = new ResponseEntity();
        responseEntity.setCode(500);
        responseEntity.setMsg(msg);
        responseEntity.setData(null);
        return responseEntity;
    }
}
